﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PluginService.Common;
using PluginService.Common.Model;
using PluginService.Base;



namespace CameraService
{
    public class WebServerCameraManager:CameraManager
    {

        #region 变量

        const int _port = 8080;

        protected string _getCameraJsonUrl = string.Format("http://{0}/get_cameras", Consts.WEBSERVER_URL);

        #endregion

        

        protected override List<CameraEntity> GetCameraEntity(string configpath)
        {
            var response = Util.GetJsonFromWeb(_getCameraJsonUrl);
            if (response != null)
            {
                try
                {
                    var engity = Newtonsoft.Json.JsonConvert.DeserializeObject<RequestResponseEntity<List<CameraEntity>>>(response);
                    return engity.Data;
                }
                catch(Exception ex)
                {
                    _log.Error(ex);
                }
                

            }
            return null;
        }
    }
}
